home *** CD-ROM | disk | FTP | other *** search
- Path: news.rain.org!usenet
- From: "Guus Leeuw jr." <guusl@eiffel.com>
- Newsgroups: comp.lang.c
- Subject: Re: Please Please Help! - pointer notation
- Date: Sat, 24 Feb 1996 09:27:01 -0800
- Organization: Interactive Software Engineering Inc. http://www.eiffel.com/
- Message-ID: <312F4A65.794A5217@eiffel.com>
- References: <4gnlv9$1fh@news.mistral.co.uk>
- NNTP-Posting-Host: @outback.eiffel.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
-
- Mike Barnard wrote:
- >
- [snip snip]
- > I've read my C book. I've gotten th C FAQ. I've read the file
- > "ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
- > following. Can you help?
-
- Probably time to throw at least the book and the `.txt' outta the window ;-)
-
- >
- > Sometimes when prototyping a function the function name is pre-fixed
- > by an asterisk. Why? What does it mean? This is a quote from the
- > pointer tutorial text by Ted Jensen...
-
- Well, go from here:
- `int foo()' means `foo()' is a function returning an `int`. Right? Right.
- `char *str' means `str' is a pointer to `char'. Right? Right.
-
- Let's mix the previous ones a bit up and we get:
- `char *bar()' means 'bar()' is a function returning a pointer to `char' ... !
-
- (I'd rather write it like `char* bar()', but that's just my $0.02)
-
- >
- [snip snip]
- >
- > Putting an asterisk before a variable name declares it as a pointer
- > variable. Putting one before the variable in use means you want to
- > access the data pointed to. Why is there sometimes an asterisk AFTER a
- > variable?
- >
- > (And I can't find a quote at the moment...)
-
- Let me give you one:
-
- int main()
- {
- int a, b;
-
- a = 4;
- b = a * 3; /* Now the asterisk's after a variable?? */
-
- return 1;
- }
-
- Seriously, I never came across an asterisk after a variable that meant other than
- multiply. Might be my inexperience as well.
-
- Hope the more serious parts might help,
- Guus Leeuw jr.
-